package classifier;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;
import java.util.Random;

public class RandomClassifier implements Classifier {
	private Random random = new Random();

	@Override
	public void test(String file, String output) {
		try {
			BufferedReader br = new BufferedReader(new FileReader(file));
			BufferedWriter bw = new BufferedWriter(new FileWriter(output));
			
			bw.append("label 1 0\n");
			
			while (br.ready()) {
				String line = br.readLine();
				
				double score = predict(line);
				int label = score > 0.5 ? 1 : 0;
				
				bw.write(label + " " + score + " 0\n");
			}
			
			br.close();
			bw.close();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	@Override
	public void train(String file, List<String> args) {
		// do nothing
	}
	
	protected double predict(String line) {
		return random.nextDouble();
	}
}
